//
//  SRAccountDataSource.m
//  SportRing
//
//  Created by mykoma on 14/10/26.
//  Copyright (c) 2014年 HotOne. All rights reserved.
//

#import "SRAccountNetSource.h"

@implementation SRAccountNetSource

//登录
+ (void)loginWithUserName:(NSString *)userName
                 userPwd:(NSString *)userPwd
                  success:(CompletionBlockWithDictionary)success
                  failure:(CompletionBlockWithError)failure
{
    [self postAction:@"v1/UserInfo/Login"
          parameters:@{@"userName":userName,
                       @"userPwd":userPwd}
             success:success
             failure:failure];
}

//注册
+ (void)registerWithUserName:(NSString *)userName
                     userPwd:(NSString *)userPwd
                    nickName:(NSString *)nickName
                     success:(CompletionBlockWithDictionary)success
                     failure:(CompletionBlockWithError)failure
{
    [self postAction:@"v1/UserInfo/Register"
          parameters:@{@"userName":userName,
                       @"userPwd":userPwd,
                       @"nickName":nickName}
             success:success
             failure:failure];
}


//修改给人资料
+ (void)updateProfileWithToken:(NSString *)token
                      nickName:(NSString *)nickName
                      birthDay:(NSString *)birthDay
                        weight:(NSNumber *)weight
                        height:(NSNumber *)height
                        gender:(NSNumber *)gender
                       success:(CompletionBlockWithDictionary)success
                       failure:(CompletionBlockWithError)failure
{
    [self postAction:@"v1/UserInfo/UpdateProfile"
          parameters:@{@"token":token,
                       @"nickName":nickName,
                       @"birthDay":birthDay,
                       @"weight":weight,
                       @"height":height,
                       @"gender":gender}
             success:success
             failure:failure];
}

//获取个人资料
+ (void)getProfileWithToken:(NSString *)token
                    success:(CompletionBlockWithDictionary)success
                    failure:(CompletionBlockWithError)failure
{
    [self postAction:@"v1/UserInfo/GetProfile"
          parameters:@{@"token":token}
             success:success
             failure:failure];
}

//忘记密码
+ (void)getAuthCodeWithPhoneNumber:(NSString *)phone
                           success:(CompletionBlockWithDictionary)success
                           failure:(CompletionBlockWithError)failure
{
    [self postAction:@"v1/UserInfo/ForgetPassword"
          parameters:@{@"phoneNumber":phone}
             success:success
             failure:failure];
}

//修改密码
+ (void)modifyPasswordWithSms:(NSString *)sms
                       newPwd:(NSString *)newPwd
                  phoneNumber:(NSString *)phoneNumber
                      success:(CompletionBlockWithDictionary)success
                      failure:(CompletionBlockWithError)failure
{
    [self postAction:@"v1/UserInfo/ModifyPassword"
          parameters:@{@"sms":sms, @"newPwd":newPwd ,@"phoneNumber":phoneNumber}
             success:success
             failure:failure];
}

+ (void)modifyWithToken:(NSString *)token
            userHeadImg:(NSData *)imageData
                success:(CompletionBlockWithDictionary)success
                failure:(CompletionBlockWithError)failure
{
    [self postAction:@"v1/UserInfo/ModifyHeadPhoto"
          parameters:@{@"token":token}
                data:imageData
            mimeType:@"image/png"
            fileName:@"file.png"
             success:success
             failure:failure];
}

@end
